package br.com.webcrm.mb;

import java.io.Serializable;

import javax.faces.application.FacesMessage;
import javax.faces.application.FacesMessage.Severity;
import javax.faces.context.FacesContext;

import org.springframework.beans.factory.annotation.Autowired;

import br.com.webcrm.model.Usuario;
import br.com.webcrm.service.ServiceFactory;
import br.com.webcrm.util.UtilJSF;
import br.com.webcrm.util.ViewState;

@SuppressWarnings("serial")
public class BaseMB implements Serializable {

	@Autowired
	private ServiceFactory serviceFactory;

	protected ViewState viewState = new ViewState();	
	protected ViewState viewState1 = new ViewState();	
	protected ViewState viewState2 = new ViewState();	
	private String valorConsulta;
	private Integer consultaCriterio;
	private Integer consultaAtivo = 1;
	
	public ServiceFactory getServiceFactory() {
		return serviceFactory;
	}

	public void setServiceFactory(ServiceFactory serviceFactory) {
		this.serviceFactory = serviceFactory;
	}
	
	public void setMensagem(Severity severity, String titulo, String mensagem) {
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, titulo, mensagem));
	}
		
	protected Usuario getUsuarioLogado() {
		return (Usuario) UtilJSF.getObjetoSessao("usuarioLogado");
	}
	
	public ViewState getViewState() {
        return viewState;
    }

    public void setViewState(ViewState viewState) {
        this.viewState = viewState;
    }	
    
	public ViewState getViewState1() {
		return viewState1;
	}

	public void setViewState1(ViewState viewState1) {
		this.viewState1 = viewState1;
	}

	public ViewState getViewState2() {
		return viewState2;
	}

	public void setViewState2(ViewState viewState2) {
		this.viewState2 = viewState2;
	}

	public String getValorConsulta() {
		return valorConsulta;
	}

	public void setValorConsulta(String valorConsulta) {
		this.valorConsulta = valorConsulta;
	}
	
	public Integer getConsultaCriterio() {
		return consultaCriterio;
	}

	public void setConsultaCriterio(Integer consultaCriterio) {
		this.consultaCriterio = consultaCriterio;
	}

	public Integer getConsultaAtivo() {
		return consultaAtivo;
	}

	public void setConsultaAtivo(Integer consultaAtivo) {
		this.consultaAtivo = consultaAtivo;
	}

	public String getMascaraCpf() {
	    return "999.999.999-99";  
	}
	
	public String getMascaraCnpj() {
	    return "99.999.999/9999-99";  
	}
	
	public String getMascaraCep() {
		return "99.999-999";
	}
	
	public String getMascaraTelefoneSemDdd() {
		return "9999-9999";
	}
	
	public String getMascaraTelefoneComDdd() {
		return "(99)9999-9999";
	}
	
	    
}
